package com.sq.quartz.task;

import com.sq.activity.config.WebSocketServer;
import com.sq.activity.domain.ActivityPublisherApply;
import com.sq.activity.mapper.ActivityPublisherApplyMapper;
import com.sq.activity.service.IActivityPublisherApplyService;
import com.sq.common.utils.UserThreadLocal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.sq.common.utils.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 定时任务调度测试
 * 
 * @author ruoyi
 */
@Component("taskJob")
public class TaskJob {
    public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
    {
        System.out.println(StringUtils.format("执行多参方法： 字符串类型{}，布尔类型{}，长整型{}，浮点型{}，整形{}", s, b, l, d, i));
    }

    public void ryParams(String params)
    {
        System.out.println("执行有参方法：" + params);
    }

    public void ryNoParams()
    {
        System.out.println("执行无参方法");
    }


    @Autowired
    private ActivityPublisherApplyMapper activityPublisherApplyMapper;

    @Autowired
    private WebSocketServer webSocketServer;
    public void getApplyStatus() {
        List<ActivityPublisherApply> list = activityPublisherApplyMapper.selectAll();
        for (ActivityPublisherApply activityPublisherApply : list) {
            List<Long> userIds = new ArrayList<>();
            if (activityPublisherApply.getApplyStatus() == 1) {
                userIds.add(activityPublisherApply.getSysUserId());
                webSocketServer.sendMessageToConsumer("您的申请已通过,恭喜成为活动组织者!", userIds);
//                activityPublisherApplyMapper.deleteActivityPublisherApplyById(activityPublisherApply.getId());
            }else if (activityPublisherApply.getApplyStatus() == 2) {
                userIds.add(activityPublisherApply.getSysUserId());
                webSocketServer.sendMessageToConsumer("您的申请已拒绝,请重新申请~", userIds);
//                activityPublisherApplyMapper.deleteActivityPublisherApplyById(activityPublisherApply.getId());
            }
        }
    }
}
